<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <h1>聊天窗口</h1>
    后端的消息：<span id="ospan"></span>

    <input type="text" id="inp">
    <button id="btn">发送</button>
</body>

</html>
<!-- <script src="http://localhost:3000/socket.io/socket.io.js"></script> -->
<script src="http://10.10.119.134:3000/socket.io/socket.io.js"></script>
<script>
    // let websocketobj = io("http://localhost:3000")
    let websocketobj = io("http://10.10.119.134:3000")




    // 等待后端返回连接成功的消息
    websocketobj.on("a", (msg) => {
        console.log(msg);
        ospan.innerText = msg;
      
    })


    btn.onclick=function(){
        websocketobj.emit("b", inp.value)
    }




</script>